<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" indent="yes"/>
<xsl:template match="Contenido/MiWebSiteContent">
 
  
<div>
<h1 id="TituloContent"><xsl:value-of select="Titulo"/> </h1>
<div id="MainContenContainer">
  <xsl:choose>
    <xsl:when test="contains(Contenido,'&lt;input')">
      <form id="formularioContacto" action="" method="post">
        <div id="SectionContent">
          <xsl:value-of select="Contenido" disable-output-escaping="yes"/>
          <input type="submit" name="BotonEnviaFormulario" value="Enviar Formulario"/>
          <input type="hidden" name="FormFields" id="FormFields"/>
        </div>
        
      </form>
      <div id="resultadoFormulario"></div>
      <script>
        $().ready(function(){
        ProcesarFormulario();
        var options = {
        target: '#resultadoFormulario',
        beforeSubmit:function(){ $("#formularioContacto input[type='submit']").attr('disabled',true).val("Procesando Formulario. por favor espere.");},  // pre-submit callback
        success: minFields
        };
        $("input[name='nombre'],input[name='email']").addClass("required");
        $("input[name='email']").addClass("email");
        $('#formularioContacto').validate({messages:{required:"Este Campo es Obligatorio",email:"Escriba un Email Valido"}});
        $('#formularioContacto').ajaxForm(options);
        });


        function ProcesarFormulario()
        {
        var formInputs = $("#formularioContacto input,#formularioContacto textarea");
        //alert(formInputs.length);
        for( var x = 0; x &lt; formInputs.length; x++ )
          {
	          if (formInputs[x].name!='FormFields' &amp;&amp; formInputs[x].type!='submit')
        {
        if (x==0)
        {
        $('#FormFields').val(formInputs[x].name);
        }
        else
        {
        $('#FormFields').val($('#FormFields').val() + '|' + formInputs[x].name);
        }
        }
        }
        
        }

        function minFields()
        {
        //var formInputs = $("#formularioContacto input,#formularioContacto textarea");
        //for( var x = 0; x &lt; formInputs.length; x++ )
        //{
        //$("#formularioContacto [name='"+formInputs[x].name+"']").hide('slow');
        //}
        
        $('#SectionContent').hide('slow');
        }


      </script>
      <style>
        .error{background:#ff5555;}
      </style>
    </xsl:when>
    <xsl:otherwise>
      <div id="SectionContent">
        <xsl:value-of select="Contenido" disable-output-escaping="yes"/>
      </div>
    </xsl:otherwise>
  </xsl:choose>
  
  
  <xsl:element name="input">
    <xsl:attribute name="type">hidden</xsl:attribute>
    <xsl:attribute name="id">ContentName</xsl:attribute>
    <xsl:attribute name="name">ContentName</xsl:attribute>
    <xsl:attribute name="value">
    <xsl:value-of select="ContentName" disable-output-escaping="yes"/>
    </xsl:attribute>
    </xsl:element>
  <xsl:element name="input">
    <xsl:attribute name="type">hidden</xsl:attribute>
    <xsl:attribute name="id">contentKeywords</xsl:attribute>
    <xsl:attribute name="name">contentKeywords</xsl:attribute>
    <xsl:attribute name="value">
      <xsl:value-of select="Keywords" disable-output-escaping="yes"/>
    </xsl:attribute>
  </xsl:element>
</div>
</div>

</xsl:template>
  <xsl:template match="Contenido/Portada/MiWebSiteContent">

    <div>
      <h1 id="TituloContent">
        <xsl:value-of select="Titulo"/>
      </h1>
      <div id="MainContenContainer">
        <div id="SectionContent">
          <xsl:value-of select="Contenido" disable-output-escaping="yes"/>
        </div>
        <xsl:element name="input">
          <xsl:attribute name="type">hidden</xsl:attribute>
          <xsl:attribute name="id">ContentName</xsl:attribute>
          <xsl:attribute name="name">ContentName</xsl:attribute>
          <xsl:attribute name="value">
            <xsl:value-of select="ContentName" disable-output-escaping="yes"/>
          </xsl:attribute>
        </xsl:element>
        <xsl:element name="input">
          <xsl:attribute name="type">hidden</xsl:attribute>
          <xsl:attribute name="id">contentKeywords</xsl:attribute>
          <xsl:attribute name="name">contentKeywords</xsl:attribute>
          <xsl:attribute name="value">
            <xsl:value-of select="Keywords" disable-output-escaping="yes"/>
          </xsl:attribute>
        </xsl:element>
      </div>
    </div>
    
  </xsl:template>
</xsl:stylesheet>
